import {defineStore} from 'pinia'
import {ref} from 'vue'
export const useMemberStore = defineStore('member',()=>{
    //cookie
    const loginState = ref({
        cookie:'',
        state:0
    })
    //设置cookie
    const setCookie = (cookie:string)=>{
        loginState.value.cookie = cookie
        loginState.value.state = 1
       
        
    }
    //清除cookie
    const clearCookie=()=>{
        loginState.value.cookie=''
        loginState.value.state = 0
    }
    return {
        loginState,
        setCookie,
        clearCookie
    }
}, {
    // #ifdef H5
    // 网页端配置
    persist: true,
    // #endif
    
    // #ifdef MP-WEIXIN
    // 小程序端配置
    persist: {
      storage: {
        getItem(key) {
          return uni.getStorageSync(key)
        },
        setItem(key, value) {
          uni.setStorageSync(key, value)
        },
      },
    },
    // #endif
    
  },)